﻿<%@ Page Language="C#" MasterPageFile="~/Back/BackgroundMain.master" AutoEventWireup="true"
    CodeFile="BgArticleEdit.aspx.cs" Inherits="Back_BgArticleEdit" Title="Untitled Page" %>

<%@ Register TagPrefix="ftb" Namespace="FreeTextBoxControls" Assembly="FreeTextBox" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<script type="text/javascript">
     function CheckData()
     {
        var Title = document.getElementById("ctl00_ContentPlaceHolder1_tb_Title").value;
        if(Title=="")
        {
            alert("请填写文章标题!");
            return false;
        }
        
        var ContentID = "<%=ContentClientID %>";
        var Content = document.getElementById(ContentID).value;
        if(Content=="")
        {
            alert("请填写文章内容!");
            return false;
        }
         var Index = <%=MaxID %>;
         
         var isCheck = false;
         var listCheckValue = [];
         for(var i=0; i<=Index; i++)
         {
            var check = document.getElementById("TypeCode" + i);
            if(check != null)
            {
                if(check.checked)
                {
                   isCheck = true;
                   listCheckValue[listCheckValue.length] = check.value;
                }
            }
         }

         var FieldID = "<%=FieldClientID %>";
         document.getElementById(FieldID).value = listCheckValue;
          
         return true;
     }
     

      function AddData()
      {   
         var isCheck = false;
         var CheckValue ;
         var check = document.getElementById("WZGG");
         if(check != null)
         {
             if(check.checked)
             {
               isCheck = true;
               CheckValue = check.value;
             }
         }
         
         var SpValueID="<%=SpValueID %>";
         CheckValue=document.getElementById(SpValueID).value;
         CheckValue=check.value;
         document.getElementById(SpValueID).value = CheckValue;
         alert(document.getElementById(SpValueID).value);
         return true;
      }
    </script>
    <div class="centertop" id="dvNav" runat="server">
        当前位置：<a href="BgArticleList.aspx">中共重庆市沙坪坝区委统一战线工作部</a>&nbsp;>>&nbsp;<a href="BgArticleList.aspx">文章管理</a>&nbsp;>>&nbsp;编辑文章</div>
    <div id="content" style="text-align: left; padding-left: 22px;">
        <div style="padding-top: 10px;">
            标题:&nbsp;<asp:TextBox ID="tb_Title" runat="server" CssClass="textbox" Width="300px"></asp:TextBox>
        </div>
        <div style="padding-top: 10px;">
            类型:&nbsp;
            
             <br />
            <asp:Panel ID="panelType" runat="server">
            
             <%
                 System.Data.DataTable _ParentType = ParentType;
                 System.Data.DataTable _ChildType = ChildType;
                 System.Data.DataTable _SelectedCheckbox= SelectedCheckbox;
                 string  _checked=NoticeChecked;
             for(int i=0;i<_ParentType.Rows.Count;i++) 
             {
                 string ParentTypeName=ParentType.Rows[i]["TypeName"].ToString();
                 string ParentTypeCode=ParentType.Rows[i]["TypeCode"].ToString();
                 if (_ParentType.Rows[i]["ParentType"].ToString() == "NOBB")
                 { %> 
                   <input type="checkbox" onclick="AddData()" <%=_checked %> id="WZGG" value="WZGG" name="WZGG" /><strong> <% =_ParentType.Rows[i]["TypeName"]%></strong>
                 <%}else{ %> 
                  <strong > <% =_ParentType.Rows[i]["TypeName"]%></strong>  <br />
                 <%} %>
                <div id="div<%=i %>">
                 <% for( int j=0;j< _ChildType.Rows.Count; j++) 
                    {  
                        if ( _ChildType.Rows[j]["ParentType"].ToString() == _ParentType.Rows[i]["TypeCode"].ToString())
                        {
                           
                            string TypeName = _ChildType.Rows[j]["TypeName"].ToString();
                            string TypeCode = _ChildType.Rows[j]["TypeCode"].ToString();
                            string TypeID = _ChildType.Rows[j]["ID"].ToString();
                            string CheckBoxName = "TypeCode" + TypeID;
                            bool isCheck = false;
                            for(int k=0;k<_SelectedCheckbox.Rows.Count;k++){
                                if(_SelectedCheckbox.Rows[k]["TypeCode"].ToString()== _ChildType.Rows[j]["TypeCode"].ToString()){

                                    isCheck = true;
                                    
                                    break;
                                }
                           } %>
                           
                           <% if (isCheck)
                              { %>
                                    <input type="checkbox" onclick="CheckData()"  checked="true" id="<%=CheckBoxName %>"  value="<%=TypeCode %>" /><%=TypeName%>
                                
                           <%}
                              else
                              { %>
                              <input type="checkbox" onclick="CheckData()" id="<%=CheckBoxName %>"  value="<%=TypeCode %>" /><%=TypeName %>
                              <%} %>
                     <%} %>
                 <%} %>
                 </div>
                 <br />
             <%} %>
                 </asp:Panel>  
   
        </div>
        
        <div style=" display:none">
          <asp:TextBox ID="chkvalue" runat="server"></asp:TextBox>
          <asp:TextBox ID="SpValue" runat="server"></asp:TextBox>
        </div>
        <div style="padding-top: 10px;">
            <ftb:FreeTextBox ID="ftb_Content" ToolbarLayout="ParagraphMenu,FontFacesMenu,FontSizesMenu,FontForeColorsMenu,FontBackColorsMenu,SymbolsMenu|Bold,Italic,Underline,Strikethrough,Superscript,Subscript;CreateLink,Unlink|JustifyLeft,JustifyRight,JustifyCenter,JustifyFull;BulletedList,NumberedList,Indent,Outdent|SelectAll,Cut,Copy,Find,Paste,Delete;Undo,Redo,RemoveFormat|InsertRule,InsertDate,InsertTime,WordCount,InsertFieldSet,WordClean,WordPaste,InsertImageFromGallery,InsertTable"
                ImageGalleryPath="~/images" Language="zh-CN" runat="server">
            </ftb:FreeTextBox>
        </div>
        <div style="padding-top: 10px; text-align: right; padding-right: 70px">
            <asp:Button ID="Submit_Btn" CssClass="button" runat="server" Text="提交" OnClick="Submit_Btn_Click"
                ValidationGroup="PostInfo" />
            &nbsp;&nbsp; &nbsp;&nbsp;
            <asp:Button ID="Cancel_Btn" runat="server" Text="返回" CssClass="button" OnClick="Cancel_Btn_Click" />
        </div>
        <div class="errorlist">
            <asp:ValidationSummary ID="ValidationSummary1" ShowSummary="true" runat="server"
                HeaderText="请看下面的出错信息：" ValidationGroup="PostInfo" />
            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="tb_Title"
                ValidationGroup="PostInfo" ErrorMessage="请输入文章标题！" Display="None"></asp:RequiredFieldValidator>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="ftb_Content"
                ValidationGroup="PostInfo" ErrorMessage="请输入文章内容！" Display="None"></asp:RequiredFieldValidator>
        </div>
    </div>
</asp:Content>
